package com.linh.trade.algo;

import com.linh.trade.algo.Move.Action;
import com.linh.trade.data.Point;

public class WindowBasedTrendFollower implements Strategy {
	public static final double HURDLE_UNIT = Math.pow(10, -4);
	private TrendFinder trendFinder;

	private double hurdle;

	public WindowBasedTrendFollower(TrendFinder trendFinder, double hurdle) {
		super();
		this.trendFinder = trendFinder;
		this.hurdle = hurdle;
	}

	public Move nextMove(Point nextPoint) {
		trendFinder.newPoint(nextPoint);
		Trend trend = trendFinder.getCurrentTrend();
		double strength = trend.getStrength();
		double abs = Math.abs(strength);
		String momentum = trend.getMomentum();
		Action action = Action.DO_NOTHING;
		if (TradingPattern.getGoLongPatterns().contains(momentum)
				&& abs > hurdle) {
			action = Action.GO_LONG;
		} else if (TradingPattern.getGoShortPatterns().contains(momentum)
				&& abs > hurdle) {
			action = Action.GO_SHORT;
		}

		return new Move(strength, action);
	}

}
